package android.slc.module.sys.ui.dict.data

import android.slc.appbase.ui.AppView
import android.slc.appbase.utils.AppIntentUtils
import android.slc.box.commonlibrary.compat.SlcResourceUtils
import javafx.fxml.FXML
import javafx.scene.control.Button


/**
 * @author slc
 * @date 2022/03/21 下午 3:34
 */
class DictDataPageView : AppView<DictDataPageVm>() {

    @FXML
    lateinit var actionAdd: Button

    override fun onBindViewBefore() {
        super.onBindViewBefore()
    }

    override fun onBindView() {
        super.onBindView()
        this.requireWindow().title = SlcResourceUtils.getString("app_label_dict_data_list")
        this.actionAdd.setOnAction {
            launcherWindow(
                DictDataEditView::class.java,
                DictDataViewConfig.getEditLauncherConfig(),
                viewModel.addEditIntentScope.apply {
                    this.bundle = AppIntentUtils.getBundleByData(viewModel.dictType)
                })
        }
        val dictDataPageVd = DictDataPageVd()
        dictDataPageVd.init(boxContentPane, viewModel.dictDataPageVmBox)
        dictDataPageVd.editDictDataAction = {
            launcherWindow(
                DictDataEditView::class.java,
                DictDataViewConfig.getEditLauncherConfig(),
                viewModel.addEditIntentScope.apply {
                    this.bundle = AppIntentUtils.getBundleByData(it)
                })
        }
    }

    override fun onBindViewLater() {
        super.onBindViewLater()
        viewModel.initVm()
    }

}